package com.itheima.table03;

import com.itheima.bean.Course;
import com.itheima.bean.Student;
import com.itheima.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class Test03 {
    @Test
    public void findAll() {
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        ManyToManyMapper mapper = sqlSession.getMapper(ManyToManyMapper.class);
        List<Student> list = mapper.findAll();
        for (Student student : list) {
            System.out.println(student.getId() + "," + student.getName() + "," + student.getAge());
            List<Course> courses = student.getCourses();
            for (Course course : courses) {
                System.out.println(course);
            }
        }
    }
}
